package com.lottery.obtainData;

import com.lottery.obtainData.AchieveDataImpl.BJSCAchieveDataImpl;
import com.lottery.obtainData.AchieveDataImpl.SscAchieveDataImpl;
import com.lottery.utils.lobbyUtils.impl.BjscPlayUtilImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 停止开奖
 */
@Component
public class Obser implements ApplicationListener<ContextRefreshedEvent> {

	@Resource
	private SscAchieveDataImpl SscAchieveImpl;
	@Resource
	private BJSCAchieveDataImpl bjscAchieveImpl;

	/*
	 * @Autowired Verification verification;
	 */

	@Autowired
	ThreadRedisRead threadRedisRead;


	@Override
	public void onApplicationEvent(ContextRefreshedEvent event) {
		if (event.getApplicationContext().getParent() == null) {

			SscAchieveImpl.lotteyType=1;
			bjscAchieveImpl.lotteyType=3;

			// root
			// application
			// context
			// 没有parent，他就是老大.
			// 需要执行的逻辑代码，当spring容器初始化完成后就会执行该方法。
			Thread thread = new Thread(SscAchieveImpl);
			thread.start();
			Thread thread2 = new Thread(bjscAchieveImpl);
			thread2.start();
			Thread thread3 = new Thread(threadRedisRead);
			thread3.start();
//			Thread thread4 = new Thread(threadRobotOnlineNum);
//			thread4.start();
		}
	}

}
